package com.sxhuayuan.parking.controller.parkinglot.user;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sxhuayuan.parking.compenent.Pageable;
import com.sxhuayuan.parking.compenent.web.RespMessage;
import com.sxhuayuan.parking.controller.BaseController;
import com.sxhuayuan.parking.entity.ParkingLotUser;
import com.sxhuayuan.parking.service.OrderRefundService;
import com.sxhuayuan.parking.service.ParkingLotUserService;

/**
 * 退款
 * 
 * @author 何龙
 * @create 2019-07-29 15:53
 */
@RestController("parkinglotuserOrderRefundController")
@RequestMapping("/parkinglotuser/order-refund")
public class OrderRefundController extends BaseController {
	@Resource(name = "parkingLotUserServiceImpl")
	ParkingLotUserService parkingLotUserService;
	@Resource(name = "orderRefundServiceImpl")
	OrderRefundService service;

	@RequestMapping("/list")
	public RespMessage list(@RequestBody Pageable pageable) {
		pageable = pageable == null ? new Pageable() : pageable;
		ParkingLotUser current = parkingLotUserService.getCurrent();
		if (current == null) {
			return invalidToken();
		}
		return successResp(service.findPage(pageable, current));
	}

	@PostMapping("/sum")
	public RespMessage sum(@RequestBody Pageable pageable) {
		pageable = pageable == null ? new Pageable() : pageable;
		ParkingLotUser current = parkingLotUserService.getCurrent();
		if (current == null) {
			return invalidToken();
		}
		return successResp(service.sumByFindPage(pageable, current));
	}
}
